package top.lyc829.zzl_android.ui.profile.follow.user;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.module.LoadMoreModule;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;

import okhttp3.internal.Util;
import top.lyc829.zzl_android.MyApp;
import top.lyc829.zzl_android.R;
import top.lyc829.zzl_android.logic.bean.UserInfoBean;
import top.lyc829.zzl_android.logic.util.Utils;

public class FollowUserAdapter extends BaseQuickAdapter<UserInfoBean, BaseViewHolder>implements LoadMoreModule {

    public FollowUserAdapter() {
        super(R.layout.followed_user_item);
    }
    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, UserInfoBean userInfoBean) {
        baseViewHolder.setText(R.id.followed_user_nickname,userInfoBean.getNickname());
        baseViewHolder.setText(R.id.followed_user_signature,userInfoBean.getSignature());

//        if(userInfoBean.getIsLike().equals("0"))
//        {
//            baseViewHolder.setText(R.id.followed_user_attentioned,"关注");
//            baseViewHolder.setBackgroundResource(R.id.followed_user_attentioned,R.drawable.btn_un_attentioned);
//        }
//        else if(userInfoBean.getIsLike().equals("1"))
//        {
//            baseViewHolder.setText(R.id.followed_user_attentioned,"已关注");
//            baseViewHolder.setBackgroundResource(R.id.followed_user_attentioned,R.drawable.btn_attentioned);
//        }

        if(userInfoBean.getIsLike().equals("-1"))
        {
            baseViewHolder.setVisible(R.id.followed_user_attentioned,false);
        }
        else if(userInfoBean.getIsLike().equals("-2"))
        {
            baseViewHolder.setVisible(R.id.followed_user_attentioned,true);
            baseViewHolder.setText(R.id.followed_user_attentioned,"已关注");
            baseViewHolder.setBackgroundResource(R.id.followed_user_attentioned,R.drawable.btn_attentioned);
        }

        Utils.Sout(userInfoBean.toString());
        Glide.with(MyApp.getContext())
                .load(userInfoBean.getAvatarUrl())
                .into((ImageView) baseViewHolder.getView(R.id.followed_user_avatar));
    }
}

